/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package siswa;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.charset.StandardCharsets;

/**
 *
 * @author Rendra
 */
public class Common {
    private int j_smk, j_sma;
    private String destPath;
    
    public int getJumlahTujuan(String pil) {
        if (pil.equals("SMA")) {
            return j_sma;
        } else {
            return j_smk;
        }
    }
    
    public void addJumlahTujuan(String pil) {
        if (pil.equals("SMA")) {
            this.j_sma++;
        } else {
            this.j_smk++;
        }
    }
    
    public int getTotalSiswa() {
        return j_sma + j_smk;
    }
    
    public void writeTextFile(String text, String aFileName) throws IOException {
        File fl = new File(aFileName);
        FileOutputStream fop = null;
        try {
            fop = new FileOutputStream(fl);
            byte[] contentInBytes = text.getBytes(StandardCharsets.UTF_8);
            fop.write(contentInBytes);
            fop.flush();
            fop.close();
        } catch (IOException e) {
        } finally {
            try {
                if (fop != null)
                    fop.close();
            } catch (IOException e) { }
        }
    }
    
    public String getWorkDir() {
        return destPath;
    }
    
    public void setWorkDir(String path) {
        destPath = path;
    }
}
